#include "cpu/exec/template-start.h"
#define instr call

make_helper(concat(call_i_, SUFFIX)) {
    int len = concat(decode_i_, SUFFIX)(cpu.eip + 1); //decode_i函数的参数指向立即数地址
    REG(R_ESP) -= 4; //开栈空间
    MEM_W(REG(R_ESP), cpu.eip + len + 1); //存放下一条（返回时）指令地址
    uint32_t imm = op_src->val;
    print_asm("call\t0x%x", cpu.eip + 1 + len + imm);
    cpu.eip += imm; //返回之后cpu-exec()函数会使eip指向下一条命令，因此eip 只需要+imm
    return len + 1; //返回该条指令的长度
}
make_helper(concat(call_rm_, SUFFIX)) {
    int len = concat(decode_rm_, SUFFIX)(cpu.eip + 1);
    REG(R_ESP) -= 4;
    MEM_W(REG(R_ESP), cpu.eip + len + 1);
    cpu.eip = op_src->val - len - 1;
    print_asm("call\t0x%x", op_src->val);
    return len + 1;
}

#include "cpu/exec/template-end.h"